package com.self.match.rocketmq;

import com.self.common.param.Order;
import com.self.match.disruptor.DisruptorTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.stereotype.Component;

/**
 * @version v1.0
 * @ClassName: OrderConsummerListener
 * @Description:
 * @Author: Mac
 */
@Slf4j
@Component
public class OrderConsummerListener {

    @Autowired
    private DisruptorTemplate disruptorTemplate;

    /**
     * @Title: 监听消息渠道处理信息
     * @Description: 
     * @Param [order]
     * @Return void
     * @Author Mac
     * @Throws
     * @Date 2022/9/3 21:29
     */
    @StreamListener("order_in")
    public void handlerMessage(Order order){
        //取消订单
        if (order.getOrderStatus() != null && order.getOrderStatus() ==2){
            order.setIfCancel(true);
        }
        log.info("接收到了委托单:{}",order);
        disruptorTemplate.start(order);
    }
}
